//dom加载完后，初始化
$(function() {
	console.log("echarts:"+ echarts.version) //查看echarts版本
	echartsBuild.initData();
	//地图展示
		//各地市站点总量
		//各地市站点分类及打点
		//运营车总量
		//客运人流总量
		//售票收入总额
	var data= [
	  {name: "杭州市", value: 1032},
	  {name: "湖州市", value: 2156},
	  {name: "嘉兴市", value: 2257},
	  {name: "宁波市", value: 36},
	  {name: "舟山市", value: 1151},
	  {name: "丽水市", value: 3242},
	  {name: "衢州市", value: 3230},
	  {name: "金华市", value: 9422},
	  {name: "台州市", value: 3129},
	  {name: "绍兴市", value: 927},
	  {name: "温州市", value: 3274}
	];
	echartsBuild.initMap(document.getElementById("mapData"),data,"","");
	// var myChart = echarts.init(document.getElementById("mapData"));
	// make_city("绍兴",myChart);
	
	//进入驾驶舱与共同富裕，省市级切换
	
	$("#prosperity").click(function() {
		var levelgov = $("#levelgov").val();
		if(levelgov == 1) {//省级
			window.open("cityBus/prosperity.html","_self");
		}else {
			window.open("cityBus/sxprosperity.html","_self");
		}
	});
	
	$("#proCityBus").click(function() {
		var levelgov = $("#levelgov").val();
		if(levelgov == 1) {//省级
			window.open("cityBus/proCityBus.html","_self");
		}else {
			window.open("cityBus/sxCityBus.html","_self");
		}
	});
	
	//默认初始化显示浙江省
	var title = $("#titles").text();
	$("title").text(title.replace("{}","浙江省"));
	$("header h1").text(title.replace("{}","浙江省"));
	
	i = 0;
	var t = setInterval("addNum(100)",20);
});


function addNum(width) {
	var percents = [2500,1500,2100];
	var colors = ["#00ffff","#0055ff","#ffff7f"];
	$.each(percents,function(k,percent){
		color = colors[k];
		if(i<percent){
			i = i + 20;
			$('canvas.process').text(i);
		    drawProcess($("#process"+(k+1)),width,color);
		}else{
		    // clearInterval(t);
		}
	});
}
 
function drawProcess($this,width,color) {  
   var text = $this.text();
   var process = text.substring(0, text.length-1);   
   var canvas = $this.get(0);  
   var context = canvas.getContext('2d');  
   context.fillStyle = "rgba(255,255,255,0)";
   context.clearRect(0, 0, width, width);  
    
   context.beginPath();  
   context.moveTo(width/2, width/2);  
   context.arc(width/2, width/2, width/2, 0, Math.PI * 2, false);  
   context.closePath();  
   context.fillStyle = '#2a3252';  
   context.fill();  
    
   context.beginPath();  
   context.moveTo(width/2, width/2);    
   context.arc(width/2, width/2, width/2, 0, Math.PI * 2 * process / 500, false);  
   context.closePath();  
   context.fillStyle = color;  
   context.fill();   
    
   context.beginPath();  
   context.moveTo(width/2, width/2);  
   context.arc(width/2, width/2, width/2 - 10, 0, Math.PI * 2, true);  
   context.closePath();  
   context.fillStyle = '#2a3252';  
   context.fill();  
    
   context.beginPath();  
   context.arc(width/2, width/2, width/2 - 20, 0, Math.PI * 2, true);  
   context.closePath();  
   context.strokeStyle = '#ddd';  
   context.stroke();  
   context.font = "bold 9pt Arial";  
   context.fillStyle = color;  
   context.textAlign = 'center';  
   context.textBaseline = 'middle';  
   context.moveTo(width/2, width/2);  
   context.fillText(text, width/2, width/2);
}